# 变量定义
NPM := npm
VITE := npx vite

# 默认目标
.DEFAULT_GOAL := help

# 帮助信息
.PHONY: help
help:
	@echo "使用方法:"
	@echo "  make [target]"
	@echo ""
	@echo "可用目标:"
	@echo "  install      - 安装项目依赖"
	@echo "  dev          - 启动开发服务器"
	@echo "  build        - 构建生产版本"
	@echo "  preview      - 预览生产构建"
	@echo "  clean        - 清理构建文件和依赖"
	@echo "  lint         - 运行代码检查"

# 安装依赖
.PHONY: install
install:
	@echo "安装项目依赖..."
	@$(NPM) install

# 启动开发服务器
.PHONY: dev
dev: install
	@echo "启动开发服务器..."
	@$(NPM) run dev

# 构建生产版本
.PHONY: build
build: install
	@echo "构建生产版本..."
	@$(NPM) run build

# 预览生产构建
.PHONY: preview
preview: build
	@echo "预览生产构建..."
	@$(NPM) run preview

# 清理构建文件和依赖
.PHONY: clean
clean:
	@echo "清理构建文件和依赖..."
	@rm -rf node_modules dist

# 运行代码检查
.PHONY: lint
lint:
	@echo "运行代码检查..."
	@$(NPM) run lint

# 运行测试（如果有的话）
.PHONY: test
test:
	@echo "运行测试..."
	@$(NPM) test